#include<iostream>
#include<string>
using namespace std;
int main()
{
    int n = 0;
    cin >> n;
    string s1;
    string s2;
    int flagy = 0;
    int flags = 0;
    int flagh = 0;
    int i = 0;
    int j = 0;
    int old = n;
    while (old--)
    {
        if (j == 0)
        {
            cin >> s1;
        }
        else
        {
            cin >> s2;
            if (s1.size() < s2.size())
            {
                i = 0;
                while (i < s1.size() && i < s2.size())
                {
                    if (s1[i] == s2[i])
                        i++;
                    else
                    {
                        break;
                    }
                }
                if (i == s1.size() || s1[i] < s2[i])
                {
                    flagh++;
                    flagy++;
                }
                else
                    flags++;
            }
            else
            {
                i = 0;
                while (i < s1.size() && i < s2.size())
                {
                    if (s1[i] == s2[i])
                        i++; 
                    else
                        break;
                }
                if ((s1[i] < s2[i]))
                    flagy++;
                else
                {
                    cout << "none" << endl;
                    return 0;
                }
            }
            s1 = s2;
        }
        j++;
    }
    if (flagh == n - 1)
    {
        cout << "both" << endl;
        return 0;
    }
    else if (flagy == n - 1)
    {
        cout << "lexicographically" << endl;
    }
    else if (flags == n - 1)
    {
        cout << "lengths" << endl;
    }
    return 0;
}